	
		
	function validateName(name) {
	    var error = "";
	    //var illegalChars = /\W/; // allow letters, numbers, and underscores
	 	var alphaExp = /^[a-zA-Z']+$/;
	 	
	 	
	    if (name.value == "") {
	        name.style.background = '#A0CCE9'; 
	        error = "You didn't enter a Name.\n";
	    } else if ((name.value.length < 0) || (name.value.length > 15)) {
	        name.style.background = '#A0CCE9'; 
	        error = "The Name is the wrong length.\n";
	    }
	    else if(!name.value.match(alphaExp))
		{
			name.style.background = '#A0CCE9';
			error="Not a valid Name!\n";
		}
		else {
	        name.style.background = 'White';
	    }
	    return error;
	}
	
	function validateFirstname(name) {
	     var error = "";
	    //var illegalChars = /\W/; // allow letters, numbers, and underscores
	 	var alphaExp = /^[a-zA-Z']+$/;
	 	
	 	
	    if (name.value == "") {
	        name.style.background = '#A0CCE9'; 
	        error = "You didn't enter a First Name.\n";
	    } else if ((name.value.length < 0) || (name.value.length > 15)) {
	        name.style.background = '#A0CCE9'; 
	        error = "The First Name is the wrong length.\n";
	    }
	    else if(!name.value.match(alphaExp))
		{
			name.style.background = '#A0CCE9';
			error="Not a valid First Name!\n";
		}
		else {
	        name.style.background = 'White';
	    }
	    return error;
	}
	
	function validateLastname(name) {
	    var error = "";
	    //var illegalChars = /\W/; // allow letters, numbers, and underscores
	 	var alphaExp = /^[a-zA-Z']+$/;
	 	
	 	
	    if (name.value == "") {
	        name.style.background = '#A0CCE9'; 
	        error = "You didn't enter a Last Name.\n";
	    } else if ((name.value.length < 0) || (name.value.length > 15)) {
	        name.style.background = '#A0CCE9'; 
	        error = "The Last Name is the wrong length.\n";
	    }
	    else if(!name.value.match(alphaExp))
		{
			name.style.background = '#A0CCE9';
			error="Not a valid Last Name!\n";
		}
		else {
	        name.style.background = 'White';
	    }
	    return error;
	}
	
	function validateAddressLine(address){
		var error = "";
		if(address.value == ""){
			address.style.background = '#A0CCE9';
			error = "You didn't enter Address.\n";
		}else{
			address.style.background = 'White';
		}
		return error;
	}
	
	function validateCity(fld){
		var error = "";
		var alphaExp = /^[a-zA-Z']+$/;
		
		 if(fld.value == ""){
		 fld.style.background = '#A0CCE9';
		 error = "You didnt' enter City.\n";
		 }else if(!fld.value.match(alphaExp)){
		 	fld.style.background = '#A0CCE9';
		 	error = "Not a valid City Name!.\n";
		 }else{
			 fld.style.background = 'White';
		 }
		return error;
	}
	
	function validateCountry(fld){
		var error = "";
		var alphaExp = /^[a-zA-Z']+$/;
		
		 if(fld.value == ""){
		 fld.style.background = '#A0CCE9';
		 error = "You didnt' enter Country.\n";
		 }else if(!fld.value.match(alphaExp)){
		 	fld.style.background = '#A0CCE9';
		 	error = "Not a valid Country Name!.\n";
		 }else{
			 fld.style.background = 'White';
		 }
		return error;
	}
	
	function trim(s)
	{
	  return s.replace(/^\s+|\s+$/, '');
	}
	
	function validateEmail(fld) {
	    var error="";
	    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
	    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
	    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
	   
	    if (fld.value == "") {
	        fld.style.background = '#A0CCE9';
	        error = "You didn't enter an email address.\n";
	    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
	        fld.style.background = '#A0CCE9';
	        error = "Please enter a valid email address.\n";
	    } else if (fld.value.match(illegalChars)) {
	        fld.style.background = '#A0CCE9';
	        error = "The email address contains illegal characters.\n";
	    } else {
	        fld.style.background = 'White';
	    }
	    return error;
	}
	
	function validatePhone(fld) {
	    var error = "";
	    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    
	
	   if (fld.value == "") {
	        error = "You didn't enter a phone number.\n";
	        fld.style.background = '#A0CCE9';
	    } else if (isNaN(parseInt(stripped))) {
	        error = "The phone number contains illegal characters.\n";
	        fld.style.background = '#A0CCE9';
	    } else if (!(stripped.length == 10)) {
	        error = "The phone number is the wrong length. Make sure you included an area code.\n";
	        fld.style.background = '#A0CCE9';
	    }
	    else{
	    	fld.style.background = 'White';
	    }
	    return error;
	}

	function validatePin(fld){
		var error ="";
		var pinExp = /^[0-9]+$/;
		
		if((fld.value=="" || fld.value==null))
		{
			fld.style.background = '#A0CCE9';
			error="You didn't enter pin no.\n";
			
		}
		else if(!fld.value.match(pinExp))
		{
			fld.style.background = '#A0CCE9';
			error="Not a valid Pin Code!\n";
		}
		else if (!(fld.value.length == 6) ) {
	        fld.style.background = '#A0CCE9'; 
	        error = "The pin is the wrong length.\n";
	    }
	     else{
	    	fld.style.background = 'White';
	    }
		return error;
	}
	
	function validateSelectDept(fld){
		var error = "";
		if(fld.value == ""){
			fld.style.background = '#A0CCE9';
			error = "You didn't select Department.\n";
		}else{
			fld.style.background = 'White';
		}
		return error;
	}
	
	function validateSelectProduct(fld){
		var error = "";
		if(fld.value == ""){
			fld.style.background = '#A0CCE9';
			error = "You didn't select Product.\n";
		}else{
			fld.style.background = 'White';
		}
		return error;
	}

	function validateSelectBuyer(fld){
		var error = "";
		if(fld.value == ""){
			fld.style.background = '#A0CCE9';
			error = "You didn't select Buyer.\n";
		}else{
			fld.style.background = 'White';
		}
		return error;
	}
	
	
	function validateQuantity(fld){
		 var error = "";
		 var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');  
		 if (fld.value == "") {
	        error = "You didn't enter a Quantity.\n";
	        fld.style.background = '#A0CCE9';
	    } else if (isNaN(parseInt(stripped))) {
	        error = "The Quantity contains illegal characters.\n";
	        fld.style.background = '#A0CCE9';
	    } else if ((fld.value.length < 0) || (fld.value.length > 4)) {
	        error = "The Quantity is the wrong length.\n";
	        fld.style.background = '#A0CCE9';
	    }
	    else{
	    	fld.style.background = 'White';
	    }
	    return error;
	}

	function validateDate(fld){
       var error = "";
		if(fld.value == ""){
			fld.style.background = '#A0CCE9';
			error = "You didn't select Date.\n";
		}else{
			fld.style.background = 'White';
		}
		return error;
	}
		
	function validateSelect(fld) {
		var error = "";
		if(fld.value == ""){
			fld.style.background = '#A0CCE9';
			error = "You didn't select Buyer Name.\n";
		}else{
			fld.style.background = 'White';
		}
		return error;
	}
	
	
	function validateEmpty(fld) {
	    var error = "";
	 
	    if (fld.value.length == 0) {
	        fld.style.background = '#A0CCE9'; 
	        error = "please Enter the Required field .\n"
	    } else {
	        fld.style.background = 'White';
	    }
	    return error;  
	}
	
	function validateOptionEmpty(fld,fld1) {
    	var error = "";
 
    	if (fld.value == "" && fld1.value == "") {
	        fld.style.background = '#A0CCE9';
	        fld1.style.background = '#A0CCE9'; 
	        error = "Any one field need to be entered";
	    } else {
	        fld.style.background = 'White';
	        fld1.style.background = 'White';
	    }
	    return error;  
	}
	
	
	
	function validateUsername(fld) {
	    var error = "";
	    var illegalChars = /\W/; // allow letters, numbers, and underscores
	 
	    if (fld.value == "") {
	        fld.style.background = '#A0CCE9'; 
	        error = "You didn't enter a username.\n";
	    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
	        fld.style.background = '#A0CCE9'; 
	        error = "Username should be between 5-15.\n";
	    } else if (illegalChars.test(fld.value)) {
	        fld.style.background = '#A0CCE9'; 
	        error = "The username contains illegal characters.\n";
	    } else {
	        fld.style.background = 'White';
	    }
	    return error;
	}
	
	function validatePassword(fld) {
	    var error = "";
	    var illegalChars = /[\W_]/; // allow only letters and numbers 
	 
	    if (fld.value == "") {
	        fld.style.background = '#A0CCE9';
	        error = "You didn't enter a password.\n";
	    } else if ((fld.value.length < 7) || (fld.value.length > 15)) {
	        error = "The password is the wrong length. \n";
	        fld.style.background = '#A0CCE9';
	    } else if (illegalChars.test(fld.value)) {
	        error = "The password contains illegal characters.\n";
	        fld.style.background = '#A0CCE9';
	    } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
	        error = "The password must contain at least one numeral.\n";
	        fld.style.background = '#A0CCE9';
	    } else {
	        fld.style.background = 'White';
	    }
	   return error;
	}   
	